﻿Imports System.Runtime.InteropServices
Imports System.Text

Module modAPI
    <DllImport("coredll.dll", SetLastError:=True)> _
    Public Function GetForegroundWindow() As IntPtr
    End Function

    <DllImport("coredll.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Public Function GetWindowText(ByVal hwnd As IntPtr, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer
    End Function

    <DllImport("coredll.dll")> _
    Public Function GetCapture() As IntPtr
    End Function

    Public Declare Function SHSetImeMode Lib "aygshell" (ByVal hWnd As IntPtr, ByVal nMode As Shime_Mode) As Integer

    Public Enum Shime_Mode
        SHIME_MODE_NONE = 0
        SHIME_MODE_SPELL = 1
        SHIME_MODE_SPELL_CAPS = 2
        SHIME_MODE_SPELL_CAPS_LOCK = 3
        SHIME_MODE_AMBIGUOUS = 4
        SHIME_MODE_AMBIGUOUS_CAPS = 5
        SHIME_MODE_AMBIGUOUS_CAPS_LOCK = 6
        SHIME_MODE_NUMBERS = 7
        SHIME_MODE_CUSTOM = 8
    End Enum


    Public Sub SetKeyboardNumeric(ByVal Hnd As IntPtr)
        Dim p As Process
        p = Process.GetCurrentProcess
        If p.MainWindowHandle <> IntPtr.Zero Then
            SHSetImeMode(Hnd, Shime_Mode.SHIME_MODE_NUMBERS)
        End If
    End Sub

    Public Sub SetKeyboardNormal()
        Dim p As Process
        p = Process.GetCurrentProcess
        If p.MainWindowHandle <> IntPtr.Zero Then
            SHSetImeMode(p.MainWindowHandle, Shime_Mode.SHIME_MODE_SPELL_CAPS_LOCK)
        End If
    End Sub




End Module
